<template>
  <div>
    <el-input
      v-if="typeof value !== 'undefined'"
      :value="value"
      @input="change"
      placeholder="请输入内容"
      class="input"
    >
      <el-button
        @click="$emit('search')"
        :loading="loading"
        slot="append"
        icon="el-icon-search"
      ></el-button>
    </el-input>
    <el-button type="primary" @click="$emit('click')" v-if="$slots.default">
      <slot></slot>
    </el-button>
  </div>
</template>

<script>
export default {
  name: "Search",
  props: {
    /**
     * 搜素区的值
     */
    value: String,
    loading: Boolean,
  },
  data() {
    return {};
  },
  mounted() {},
  methods: {
    change(val) {
      this.$emit("input", val);
    },
  },
};
</script>

<style lang="scss" scoped>
.input {
  width: 300px;
}
</style>
